package com.ict.ais.realTime.service.api.impl;


import org.springframework.stereotype.Service;

import com.ict.ais.realTime.facade.api.ITargetPreciseService;
import com.ict.ais.realTime.facade.dto.ResultObj;
import com.ict.ais.realTime.facade.model.TargetLoca;
import com.ict.ais.realTime.service.dao.ITargetPreciseDao;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/5/26.
 */
@Service("targetPreciseService")
public class TargetPreciseService  implements ITargetPreciseService {
    @Resource
    ITargetPreciseDao dao;

    public ResultObj getTarByid(int id, int mode) {
        ResultObj resultObj=new ResultObj();
        List<TargetLoca> loca;
        try {
            if (mode==1){
                loca = dao.getTargetByID1(id);
                if (loca.size()<1){
                    resultObj.setState(0);
                }else{
                    resultObj.setState(1);
                    resultObj.setObj(loca);
                }
            }else {
                loca = dao.getTargetByID0(id);
                if (loca.size()<1){
                    resultObj.setState(0);
                }else{
                    resultObj.setState(1);
                    resultObj.setObj(loca);
                }
            }
        } catch (Exception e) {
            System.out.println("数据库访问错误" + e);
            resultObj.setState(-1);
        }
        return resultObj;
    }
}
